\section*{Exercise 3.7}

\begin{quote}
Assume that \$x contains a sequence of strings and 
that \$y contains a single string. Use the function 
library to write expression that compute the following results: 
\end{quote}
	
a. Whether or not \$y equals one of the strings in \$x 
\begin{lstlisting}
for \$s in \$x 
	if(\$s eq \$y)
		then return fn:true()
		else ()
return fn:false()
\end{lstlisting}
		
b. The length of the largest string occuring in \$x
\begin{lstlisting}
fn:max(
	for \$s in \$x 
		return fn:string\_length(\$s)
)
\end{lstlisting}

c. Whether or not the concatenation of strings in \$x forms a palindrome
\begin{lstlisting}
if(
	fn:codepoints-to-string(fn:reverse(fn:string-to-codepoints(fn:concat(\$x))))
	eq 
	fn:concat(\$x)
)
	then return fn:true()
	else return fn:false()
\end{lstlisting}

d. How many of the strings occuring in \$x appear as 
attribute values in the document whose URL is \$y 
\begin{lstlisting}
for \$s in \$x
	for \$r in fn:doc(\$y)//@*
		if(\$s eq \$r)
			then return fn:true()
			else ()
return fn:false()
\end{lstlisting}